Paste: cache-get* (old stack version)
Author: | dharmatech |
Mode: | factor |
Date: | Tue, 14 Oct 2008 07:19:04 |
Plain Text |
: query->rr ( query -- rr ) [ name>> ] [ type>> ] [ class>> ] tri f f rr boa ;
: query+entry->rrs ( query entry -- rrs )
swap
query->rr
over
time>> time->ttl >>ttl
swap
data>> [ >r dup clone r> >>rdata ] map
nip ;
: expired? ( entry -- ? ) time>> time->ttl 0 <= ;
: cache-get* ( query -- rrs/NX/f )
dup table-get
{
{ [ dup f = ] [ 2drop f ] }
{ [ dup expired? ] [ drop table-rem f ] }
{ [ dup nx? ] [ 2drop NX ] }
{ [ t ] [ query+entry->rrs ] }
}
cond ;
Author: | prunedtree |
Mode: | factor |
Date: | Tue, 14 Oct 2008 07:27:44 |
Plain Text |
:: (cache-get*) ( query table -- rrs/NX/f )
{
{ [ dup f = ] [ f ] }
{ [ dup expired? ] [ query table-rem f ] }
{ [ dup nx? ] [ NX ] }
{ [ t ] [ table query+entry->rrs ] }
}
cond ;
: cache-get* ( query -- rrs/NX/f )
dup table-get (cache-get*)
Author: | prunedtree |
Mode: | factor |
Date: | Tue, 14 Oct 2008 07:41:07 |
Plain Text |
: query->rr ( query -- rr ) [ name>> ] [ type>> ] [ class>> ] tri f f rr boa ;
: query+entry->rrs ( query entry -- rrs )
[ query->rr ] dip
dup time>> time->ttl >>ttl
[ data>> ] dip
[ clone swap >>rdata ] curry map
:: (cache-get*) ( query table -- rrs/NX/f )
table
{
{ [ f = ] [ f ] }
{ [ expired? ] [ query table-rem f ] }
{ [ nx? ] [ NX ] }
{ [ t ] [ query table query+entry->rrs ] }
}
cond' ;
: cache-get* ( query -- rrs/NX/f )
dup table-get (cache-get*)
New Annotation