Sun, 01 Aug 2010 01:23:32 +0100
Fix README header
0
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 | |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 | module("memcache", package.seeall); |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 | |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 | function new() |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 | local cache = {}; |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 | local _data = {}; |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 | local _flags = {}; |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 | |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 | function cache:set(key, flags, expires, data) |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 | if expires ~= 0 then |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 | return false, "Expiry is not currently implemented"; |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 | end |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 | _flags[key] = flags; |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 | _data[key] = data; |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 | return true; |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 | end |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 | |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 | function cache:get(key) |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 | return _flags[key], _data[key]; |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 | end |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 | |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 | return cache; |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 | end |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 | |
73bc20975514
Memory is the storehouse in which the substance of our knowledge is treasured up.
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 | return _M; |