errata for the Recorded Webinar: AllegroCache, An Introduction to Object Persistence in Lisp

From Wednesday, July 28th, 2010

Thank you for attending my Webinar.

The AllegroCache developer was watching and pointed out I misspoke a bit about with-transaction-restarts. I said it caught the error and retried its body, and suggested this:


   (rollback) ;; syncs local and stored

   (if (with-transaction-restart ()   

           (sell “jr1001” 6)


      (return t)))

Actually, the loop is not necessary since with-transaction-restarts itself does a (rollback) if the commit fails, so the code above simplifies to:

  (with-transaction-restart ()   

           (sell “jr1001” 6)


An initial (rollback) is not necessary since if the database value for that slot is out of sync, the commit will fail and with-transaction-restart will do the (rollback) and then re-evaluate the body. The (commit) within the body is necessary, of course.

Then our improved SELL function is:

(defun sell (perf-id number)

  (let* ((perf (retrieve-from-index 'performance 'perf-id perf-id)))

    (with-transaction-restart ()

      (let* ((avail (perf-unsold perf))

         (sold (perf-sold perf)))

    (if (<= number avail)


          (setf (perf-unsold perf) (- avail number))

          (setf (perf-sold perf) (+ sold number))


      (error "only ~d tickets available, cannot sell ~d" avail number))))))

The slides have been updated.

David Margolies

Franz Inc.

Copyright © 2018 Franz Inc., All Rights Reserved | Privacy Statement Twitter Google+