registry

Homepage: https://www.gnu.org/software/emacs

Author: Teodor Zlatanov

Summary

Track and remember data items by various fields

Commentary

This library provides a general-purpose EIEIO-based registry
database with persistence, initialized with these fields:

version: a float

max-size: an integer, default most-positive-fixnum

prune-factor: a float between 0 and 1, default 0.1

precious: a list of symbols

tracked: a list of symbols

tracker: a hash table tuned for 100 symbols to track (you should
only access this with the :lookup2-function and the
:lookup2+-function)

data: a hash table with default size 10K and resize threshold 2.0
(this reflects the expected usage so override it if you know better)

...plus methods to do all the work: `registry-search',
`registry-lookup', `registry-lookup-secondary',
`registry-lookup-secondary-value', `registry-insert',
`registry-delete', `registry-prune', `registry-size' which see

and with the following properties:

Every piece of data has a unique ID and some general-purpose fields
(F1=D1, F2=D2, F3=(a b c)...) expressed as an alist, e.g.

((F1 D1) (F2 D2) (F3 a b c))

Note that whether a field has one or many pieces of data, the data
is always a list of values.

The user decides which fields are "precious", F2 for example.  When
the registry is pruned, any entries without the F2 field will be
removed until the size is :max-size * :prune-factor _less_ than the
maximum database size.  No entries with the F2 field will be removed
at PRUNE TIME, which means it may not be possible to prune back all
the way to the target size.

When an entry is inserted, the registry will reject new entries if
they bring it over the :max-size limit, even if they have the F2
field.

The user decides which fields are "tracked", F1 for example.  Any
new entry is then indexed by all the tracked fields so it can be
quickly looked up that way.  The data is always a list (see example
above) and each list element is indexed.

Precious and tracked field names must be symbols.  All other
fields can be any other Emacs Lisp types.

Dependencies

Reverse dependencies