mirror of https://github.com/movim/movim
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.5 KiB
66 lines
1.5 KiB
<?php
|
|
|
|
namespace modl;
|
|
|
|
class CacheDAO extends SQL
|
|
{
|
|
function get($key)
|
|
{
|
|
$this->_sql = '
|
|
select * from cache
|
|
where
|
|
session = :session
|
|
and name = :name';
|
|
|
|
$this->prepare(
|
|
'Cache',
|
|
[
|
|
'session' => $this->_user,
|
|
'name' => $key
|
|
]
|
|
);
|
|
|
|
return $this->run('Cache', 'item');
|
|
}
|
|
|
|
function set(Cache $cache)
|
|
{
|
|
$this->_sql = '
|
|
update cache
|
|
set data = :data,
|
|
timestamp = :timestamp
|
|
where session = :session
|
|
and name = :name';
|
|
|
|
$this->prepare(
|
|
'Cache',
|
|
[
|
|
'session' => $this->_user,
|
|
'data' => $cache->data,
|
|
'timestamp' => $cache->timestamp,
|
|
'name' => $cache->name
|
|
]
|
|
);
|
|
|
|
$this->run('Cache');
|
|
|
|
if(!$this->_effective) {
|
|
$this->_sql = '
|
|
insert into cache
|
|
(session, name, data, timestamp)
|
|
values (:session, :name, :data, :timestamp)';
|
|
|
|
$this->prepare(
|
|
'Cache',
|
|
[
|
|
'session' => $this->_user,
|
|
'name' => $cache->name,
|
|
'data' => $cache->data,
|
|
'timestamp' => $cache->timestamp
|
|
]
|
|
);
|
|
|
|
return $this->run('Cache');
|
|
}
|
|
}
|
|
}
|