Changeset 711 for trunk/src/json


Ignore:
Timestamp:
08/04/11 19:01:13 (14 years ago)
Author:
lgiessmann
Message:

trunk: datamodel: improved caching of serialized fragments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/json/isidorus-json/json_exporter.lisp ΒΆ

    r708 r711  
    481481                 j-str))
    482482          (concat (subseq j-str 0 (- (length j-str) 1)) "}")))))
    483 
    484 
    485 ;; =============================================================================
    486 ;; --- json data fragment-serializer-cache -------------------------------------
    487 ;; =============================================================================
    488 
    489 (defgeneric set-fragment-cache (fragment)
    490   (:documentation "sets the fragment cache, no matter if the
    491                    fragment chaged or not.")
    492   (:method ((fragment FragmentC))
    493     (let ((top (topic fragment)))
    494       (setf (slot-value fragment 'serializer-notes)
    495             (list :psis (length (psis top :revision 0))
    496                   :iis (length (item-identifiers top :revision 0))
    497                   :sls (length (locators top :revision 0))
    498                   :names (length (names top :revision 0))
    499                   :occurrences (length (occurrences top :revision 0))
    500                   :roles (length (player-in-roles top :revision 0))))
    501       (setf (slot-value fragment 'serializer-cache)
    502             (json-exporter:export-construct-as-isidorus-json-string
    503              fragment :revision 0))
    504       (serializer-cache fragment))))
    505 
    506 
    507 (defgeneric serialize-fragment (fragment)
    508   (:documentation "returns a string that represent the isidours-json
    509                    serialization of the passed fragment instance.
    510                    This method uses the fragments serializer-cache
    511                    slot to perform faster, i.e. if the fragment has
    512                    not changed since the last time, the serializer-cache
    513                    is returned, otherwise the serialization is invoked
    514                    again.")
    515   (:method ((fragment FragmentC))
    516     (cond ((null (serializer-notes fragment))
    517            (set-fragment-cache fragment))
    518           ((serializer-notes-changed-p fragment)
    519            (set-fragment-cache fragment))
    520           (t
    521            (serializer-cache fragment)))))
    522            
    523          
    524                  
Note: See TracChangeset for help on using the changeset viewer.