Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
storagecache.php
1
<?php
2
namespace
Bitrix\Rest\OAuth
;
3
4
5
use
Bitrix\Main\Application
;
6
use
Bitrix\Rest\AuthStorageInterface
;
7
8
class
StorageCache
implements
AuthStorageInterface
9
{
10
const
CACHE_TTL
= 3600;
11
const
CACHE_PREFIX
=
"oauth_"
;
12
13
public
function
store
(array $authResult)
14
{
15
$cache = $this->
getCache
();
16
17
$cache->read(static::CACHE_TTL, $this->
getCacheId
($authResult[
"access_token"
]));
18
$cache->set($this->
getCacheId
($authResult[
"access_token"
]), $authResult);
19
}
20
21
public
function
rewrite
(array $authResult)
22
{
23
$cache = $this->
getCache
();
24
25
$cache->clean($this->
getCacheId
($authResult[
"access_token"
]));
26
$cache->read(static::CACHE_TTL, $this->
getCacheId
($authResult[
"access_token"
]));
27
$cache->set($this->
getCacheId
($authResult[
"access_token"
]), $authResult);
28
}
29
30
public
function
restore
($accessToken)
31
{
32
$cache = $this->
getCache
();
33
34
$authResult =
false
;
35
36
if
($readResult = $cache->read(static::CACHE_TTL, $this->getCacheId($accessToken)))
37
{
38
$authResult = $cache->get($this->
getCacheId
($accessToken));
39
}
40
41
return
$authResult;
42
}
43
44
protected
function
getCacheId
($accessToken)
45
{
46
return
static::CACHE_PREFIX.$accessToken;
47
}
48
49
protected
function
getCache
()
50
{
51
return
Application::getInstance
()->getManagedCache();
52
}
53
}
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getInstance
static getInstance()
Definition
application.php:95
Bitrix\Rest\OAuth\StorageCache
Definition
storagecache.php:9
Bitrix\Rest\OAuth\StorageCache\getCacheId
getCacheId($accessToken)
Definition
storagecache.php:44
Bitrix\Rest\OAuth\StorageCache\store
store(array $authResult)
Definition
storagecache.php:13
Bitrix\Rest\OAuth\StorageCache\CACHE_TTL
const CACHE_TTL
Definition
storagecache.php:10
Bitrix\Rest\OAuth\StorageCache\getCache
getCache()
Definition
storagecache.php:49
Bitrix\Rest\OAuth\StorageCache\CACHE_PREFIX
const CACHE_PREFIX
Definition
storagecache.php:11
Bitrix\Rest\OAuth\StorageCache\restore
restore($accessToken)
Definition
storagecache.php:30
Bitrix\Rest\OAuth\StorageCache\rewrite
rewrite(array $authResult)
Definition
storagecache.php:21
Bitrix\Rest\AuthStorageInterface
Definition
authstorageinterface.php:6
Bitrix\Rest\OAuth
Definition
auth.php:9
modules
rest
lib
oauth
storagecache.php
Создано системой
1.10.0