Changeset 29466 in project


Ignore:
Timestamp:
07/30/13 02:52:47 (6 years ago)
Author:
Ivan Raikov
Message:

memcached: consistent use of string=?, added base64 as a dependency, added more unit tests

Location:
release/4/memcached/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/memcached/trunk/memcached.meta

    r29443 r29466  
    1818 ; A list of eggs memcached depends on.
    1919
    20  (needs)
     20 (needs base64)
    2121
    2222 (test-depends test)
    2323
    24  (author "Ivan Raikov")
     24 (author "Ivan Raikov and Seth Alves")
    2525
    2626 (synopsis "Client interface to the Memcached protocol."))
  • release/4/memcached/trunk/memcached.scm

    r29443 r29466  
    169169
    170170
    171 (define (cas h key flags exptime val cas-unique)
     171(define (cas h key val cas-unique  #!key (exptime 0) (flags 0))
    172172  (let* ((key-encoder (server-handle-key-encoder h))
    173173         (value-encoder (server-handle-value-encoder h))
     
    178178    (send-line h s)
    179179    (let ((response (nread-line h)))
    180       (cond ((equal? response "STORED") #t)
    181             ((equal? response "NOT_STORED") 'not-stored)
    182             ((equal? response "EXISTS") 'exists)
    183             ((equal? response "NOT_FOUND") 'not-found)
     180      (cond ((string=? response "STORED") #t)
     181            ((string=? response "NOT_STORED") 'not-stored)
     182            ((string=? response "EXISTS") 'exists)
     183            ((string=? response "NOT_FOUND") 'not-found)
    184184            (else #f)))))
    185185
     
    233233                 (nread-line h) ;; eat \r\n
    234234                 (loop (cons (list key flags data cas-unique)
    235                              results)))))))))
     235                             results)))
     236               ))
     237        ))
     238    ))
    236239
    237240(define (get h key)
  • release/4/memcached/trunk/tests/run.scm

    r25201 r29466  
    1313(sleep 3)
    1414
     15
     16
     17(test-group "cas test"
     18 (with-server-connection h "localhost" 11211
     19     (let ((counter 1))
     20       (let ((success (set h "counter" counter)))
     21         (test-assert success)
     22         (let* ((res (car (gets h (list "counter"))))
     23                (cas-unique (cadddr res)))
     24           (test counter (caddr res))
     25           (let* ((counter1 (cas h "counter" (+ counter 1) cas-unique))
     26                  (counter2 (get h "counter")))
     27             (test counter2 (+ 1 counter))
     28             ))
     29         ))
     30     ))
     31
     32
     33(test-group "append/prepend test"
     34 (with-server-connection h "localhost" 11211
     35     (let ((foo 4))
     36       (let ((success (set h "foo" foo)))
     37         (test-assert success)
     38         (let ((success (append-to h "foo" 5)))
     39           (test-assert success)
     40           (test 45 (get h "foo"))
     41           ))
     42       ))
     43 )
     44
     45
    1546(test-group "stats test"
    1647 (with-server-connection h "localhost" 11211
     
    1849      (test-assert (and (assoc 'pid data) (assoc 'time data)
    1950                        (assoc 'version data))))))
     51
    2052
    2153(test-group "set/get test"
     
    2961           (test-assert (not foo2)))
    3062         ))))
     63
    3164         
    3265
Note: See TracChangeset for help on using the changeset viewer.