|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.alicebot.server.core.PredicateMaster
public class PredicateMaster
Maintains in-memory predicate values for userids. Every public set and get method checks the size of the cache, and saves out part of it if it has exceeded a configurable limit.
This currently has the defect that it doesn't choose intelligently which userids' predicates to cache (it should do this for the ones who have not been heard from the longest). The HashMap that contains the predicates (keyed by userid) makes no guarantees about order. :-(
Field Summary | |
---|---|
protected static int |
cacheSize
A counter for tracking the number of predicate value cache operations. |
protected static java.lang.String |
PREDICATE_EMPTY_DEFAULT
The predicate empty default. |
Method Summary | |
---|---|
protected java.lang.Object |
clone()
Prohibits cloning this class. |
static java.lang.String |
get(java.lang.String name,
int index,
java.lang.String userid,
java.lang.String botid)
Gets the predicate value associated
with a name at a given index
for a given userid . |
static java.lang.String |
get(java.lang.String name,
java.lang.String userid,
java.lang.String botid)
Gets the predicate value associated
with a name for a given userid . |
static java.lang.String |
push(java.lang.String name,
java.lang.String value,
java.lang.String userid,
java.lang.String botid)
Pushes a value onto an indexed
predicate name for a given userid ,
and returns either the name or the value ,
depending on the predicate type. |
(package private) static void |
saveAll()
Dumps the entire cache. |
static java.lang.String |
set(java.lang.String name,
int index,
java.lang.String value,
java.lang.String userid,
java.lang.String botid)
Sets a value against an indexed
predicate name for a given userid ,
and returns either the name or the value ,
depending on the predicate type. |
static java.lang.String |
set(java.lang.String name,
java.lang.String value,
java.lang.String userid,
java.lang.String botid)
Sets a predicate value against a
predicate name for a given userid,
and returns either the name or the value ,
depending on the predicate type. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static int cacheSize
protected static final java.lang.String PREDICATE_EMPTY_DEFAULT
Method Detail |
---|
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public static java.lang.String set(java.lang.String name, java.lang.String value, java.lang.String userid, java.lang.String botid)
value
against a
predicate name
for a given userid,
and returns either the name
or the value
,
depending on the predicate type.
name
- the predicate namevalue
- the predicate valueuserid
- the useridbotid
-
name
or the value
, depending on the predicate typepublic static java.lang.String set(java.lang.String name, int index, java.lang.String value, java.lang.String userid, java.lang.String botid)
value
against an indexed
predicate name
for a given userid
,
and returns either the name
or the value
,
depending on the predicate type.
name
- the predicate nameindex
- the indexvalue
- the predicate valueuserid
- the useridbotid
-
name
or the value
, depending on the predicate typepublic static java.lang.String push(java.lang.String name, java.lang.String value, java.lang.String userid, java.lang.String botid)
value
onto an indexed
predicate name
for a given userid
,
and returns either the name
or the value
,
depending on the predicate type.
name
- the predicate namevalue
- the predicate valueuserid
- the useridbotid
-
name
or the value
, depending on the predicate typepublic static java.lang.String get(java.lang.String name, java.lang.String userid, java.lang.String botid)
value
associated
with a name
for a given userid
.
name
- the predicate nameuserid
- the useridbotid
-
value
associated with the given name
,
for the given userid
public static java.lang.String get(java.lang.String name, int index, java.lang.String userid, java.lang.String botid)
value
associated
with a name
at a given index
for a given userid
.
name
- the predicate nameindex
- the indexuserid
- the useridbotid
-
value
associated with the given name
at the given index
, for the given userid
static void saveAll()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |