Common Lisp Package: CL-PREVALENCE

An implementation of Object Prevalence for Common Lisp

README:

FUNCTION

Public

DROP-INDEX-ON (SYSTEM CLASS &OPTIONAL SLOTS)

Drop indexes on each of the slots provided

INDEX-ON (SYSTEM CLASS &OPTIONAL SLOTS (TEST 'EQUALP))

Create indexes on each of the slots provided.

MAKE-PREVALENCE-SYSTEM (DIRECTORY &KEY (PREVALENCE-SYSTEM-CLASS 'PREVALENCE-SYSTEM) INIT-ARGS)

Create and return a new prevalence system on directory. When the directory contains a valid snapshot and/or transaction log file, the system will be restored. Optionally specify the prevalence system's class.

MAKE-TRANSACTION (FUNCTION &REST ARGS)

Create and return a new transaction specifying a function name and an argument list. The function should accept the system instance prepended to the argument list as arguments and implement the actual transaction in a re-entrant way.

START-MASTER-CLIENT (PREVALENCE-SYSTEM &KEY (HOST localhost) (PORT 7651))

Start a connection to host:port to deliver transactions from prevalence-system

START-SLAVE-SERVER (PREVALENCE-SYSTEM &KEY (PORT 7651))

Start a server on port accepting transactions to be executed on prevalence-system

STOP-MASTER-CLIENT (PREVALENCE-SYTEM)

Stop a connection from prevalence-system

TX-CHANGE-OBJECT-SLOTS (SYSTEM CLASS ID SLOTS-AND-VALUES)

Change some slots of the object of class with id in system using slots and values

TX-CREATE-ID-COUNTER (SYSTEM)

Initialize the id counter to 0

TX-CREATE-OBJECT (SYSTEM CLASS &OPTIONAL SLOTS-AND-VALUES)

Create a new object of class in system, assigning it a unique id, optionally setting some slots and values

TX-DELETE-OBJECT (SYSTEM CLASS ID)

Delete the object of class with id from the system

TX-SET-PREFERENCE (SYSTEM KEY VALUE)

Set the value of the persistent preference key in system

Undocumented

STOP-SLAVE-SERVER (SERVER)

Private

ADD-OBJECT-TO-SLOT-INDEX (SYSTEM CLASS SLOT OBJECT)

Add an index entry using this slot to this object

COPY-STREAM (IN OUT &OPTIONAL (ELEMENT-TYPE '(UNSIGNED-BYTE 8)))

Copy everything from in to out

GET-OBJECTS-ROOT-NAME (CLASS)

Return the keyword symbol naming the root of instances of class

GET-OBJECTS-SLOT-INDEX-NAME (CLASS &OPTIONAL (SLOT 'ID))

Return the keyword symbol naming the specified index of instances of class.

REMOVE-OBJECT-FROM-SLOT-INDEX (SYSTEM CLASS SLOT OBJECT)

Remove the index entry using this slot to this object

SLOT-VALUE-CHANGED-P (OBJECT SLOT VALUE)

Return true when slot in object is not eql to value (or when the slot was unbound)

TIMETAG (&OPTIONAL (UNIVERSAL-TIME (GET-UNIVERSAL-TIME)))

Return a GMT string of universal-time as YYMMDDTHHMMSS

TRUNCATE-FILE (FILE POSITION)

Truncate the physical file at position by copying and replacing it

TX-CREATE-OBJECTS-SLOT-INDEX (SYSTEM CLASS SLOT &OPTIONAL (TEST #'EQUALP))

Create an index for this object on this slot, with an optional test for the hash table (add existing objects)

TX-REMOVE-OBJECTS-SLOT-INDEX (SYSTEM CLASS SLOT)

Remove an index for this object on this slot

Undocumented

COPY-FILE (SOURCE TARGET)

MACRO

Public

EXECUTE-TRANSACTION (TRANSACTION-CALL)

Create a transaction object from transaction-call and execute it

GENERIC-FUNCTION

Public

ALL-PREFERENCES-KEYS (SYSTEM)

Return a list of all persistent preference keys of system

BACKUP (SYSTEM &KEY DIRECTORY)

Make backup copies of the current snapshot and transaction-log files

COPY-TO-STREAM (BLOB BINARY-OUTPUT-STREAM)

Copy the bytes from blob to binary-output-stream

DESTROY (BLOB)

Completely destroy blob (removing its byte data file as well)

EXECUTE (SYSTEM OBJECT)

Ask for a transaction object to be executed on system with ACID properties

FILL-FROM-FILE (BLOB PATHNAME)

Fill the blob's contents with the bytes read from the binary file at pathname

FILL-FROM-STREAM (BLOB BINARY-INPUT-STREAM)

Fill the blob's contents with the bytes from binary-input-stream

FIND-ALL-OBJECTS (SYSTEM CLASS)

Return an unordered collection of all objects in system that are instances of class

FIND-OBJECT-WITH-ID (SYSTEM CLASS ID)

Find and return the object in system of class with id, null if not found

FIND-OBJECT-WITH-SLOT (SYSTEM CLASS SLOT VALUE &OPTIONAL TEST)

Find and return the object in system of class with slot equal to value, null if not found

GET-FILE (BLOB)

Return the pathname to the bytes of blob

GET-OPTION (SYSTEM NAME)

Retrieve a named option from system

SETFGET-OPTION (VALUE SYSTEM NAME)

Set a named option of system to value

GET-PREFERENCE (SYSTEM KEY)

Retrieve the value of the persistent preference stored under key in system

GET-ROOT-OBJECT (SYSTEM NAME)

Retrieve a root object by symbol name from system

SETFGET-ROOT-OBJECT (VALUE SYSTEM NAME)

Set a symbol named root object of system to value

INITIATES-ROLLBACK (CONDITION)

Return true when a condition initiates a rollback when thrown from a transaction

QUERY (SYSTEM FUNCTION &REST ARGS)

Ask for a query function to be executed on system with args

REMOVE-ROOT-OBJECT (SYSTEM NAME)

Remove the root object by symbol name from system

RESTORE (SYSTEM)

Restore a system from permanent storage

SNAPSHOT (SYSTEM)

Take a snapshot of a system

TOTALLY-DESTROY (SYSTEM &KEY ABORT)

Totally destroy system from permanent storage by deleting any files that we find

Undocumented

CLOSE-OPEN-STREAMS (SYSTEM &KEY ABORT)

NEXT-ID (SYSTEM)

Private

EXECUTE-ON (OBJECT SYSTEM)

Ask for a transaction object to execute its changes in the context of system

Undocumented

GET-SNAPSHOT-FILENAME (SYSTEM &OPTIONAL SUFFIX)

GET-TRANSACTION-LOG-FILENAME (SYSTEM &OPTIONAL SUFFIX)

LOG-TRANSACTION (SYSTEM TRANSACTION)

SET-SIZE-FROM-FILE (BLOB)

SIZE-FROM-FILE (BLOB)

SLOT-ACCESSOR

Public

GET-ID (OBJECT)

The Return an external, unique, immutable identifier for object (typically an integer)

GET-KEYWORDS (BLOB)

The Return the list of keywords associated with blob

SETFGET-KEYWORDS (KEYWORDS BLOB)

The Set the keywords list of blob

GET-MIME-TYPE (BLOB)

The Return the mime-type of blob as a string

SETFGET-MIME-TYPE (MIME-TYPE BLOB)

The Set the mime-type string of blob

GET-NAME (BLOB)

The Return the descriptive name of blob

SETFGET-NAME (NAME BLOB)

The Set the descriptive name of blob

GET-SIZE (BLOB)

The Return the size of blob in bytes

Undocumented

GET-GUARD (OBJECT)

SETFGET-GUARD (NEW-VALUE OBJECT)

Private

Undocumented

GET-ARGS (OBJECT)

SETFGET-ARGS (NEW-VALUE OBJECT)

GET-DESERIALIZER (OBJECT)

SETFGET-DESERIALIZER (NEW-VALUE OBJECT)

GET-DIRECTORY (OBJECT)

SETFGET-DIRECTORY (NEW-VALUE OBJECT)

GET-FILE-EXTENSION (OBJECT)

SETFGET-FILE-EXTENSION (NEW-VALUE OBJECT)

GET-FUNCTION (OBJECT)

SETFGET-FUNCTION (NEW-VALUE OBJECT)

GET-ROOT-OBJECTS (OBJECT)

SETFGET-ROOT-OBJECTS (NEW-VALUE OBJECT)

GET-SERIALIZATION-STATE (OBJECT)

GET-SERIALIZER (OBJECT)

SETFGET-SERIALIZER (NEW-VALUE OBJECT)

GET-SNAPSHOT (OBJECT)

SETFGET-SNAPSHOT (NEW-VALUE OBJECT)

GET-TRANSACTION-HOOK (OBJECT)

SETFGET-TRANSACTION-HOOK (NEW-VALUE OBJECT)

GET-TRANSACTION-LOG (OBJECT)

SETFGET-TRANSACTION-LOG (NEW-VALUE OBJECT)

GET-TRANSACTION-LOG-STREAM (OBJECT)

SETFGET-TRANSACTION-LOG-STREAM (NEW-VALUE OBJECT)

VARIABLE

Public

*BLOB-ROOT*

The directory in which to store the blob files

CLASS

Public

BLOB

A blob is a file-like collection of bytes with related metadata

GUARDED-PREVALENCE-SYSTEM

A Prevalence system with a guard thunk

OBJECT-WITH-ID

Superclass for objects with an id

PREVALENCE-SYSTEM

Base Prevalence system implementation object

TRANSACTION

A simple Transaction object joining a function and its arguments

CONDITION

Public

NO-ROLLBACK-ERROR

Thrown by code inside a transaction to indicate that no rollback is needed