[[local_space_interface]]
== Local Space interface

The +Space+ implementation is designed to be easy to implement under
different scenarios, such as persistent spaces, remote spaces, replicated
spaces. 

The +LocalSpace+ interface enhances the +Space+ interface in situations where
the implementation runs in a single JVM, such as the +TSpace+ implementation.

The additional methods include:

[source,java]
----
public interface LocalSpace {
    public void addListener (Object key, SpaceListener listener);
    public void addListener (Object key, SpaceListener listener, long timeout);
    public void removeListener (Object key, SpaceListener listener);
}
----

as well as some miscellaneous methods that could be expensive to transmit over the wire and were left out in the base +Space+ implementation.

[source,java]
----
    public Set getKeySet ();
    public int size (Object key);
----

The +SpaceListener+ implementation looks like this:

[source,java]
--------
public interface SpaceListener {
    public void notify (Object key, Object value);
}
--------

[NOTE]
======
With the +LocalSpace+ we can create event-driven consumers that allows us to
reduce the number of threads. A good example is the thread-less lightweight
+QMUX+ implementation.
======

