UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'APQGapqsBYYKAZh2S6WObX2pTeX1KbfgIdoKVLwXkhA='
WHERE
key_id = '668b398eb486072fd77df081e0e7dc430ba5df39669ef97512c2364b30b718c0'
AND (
token = 'APQGapqsBYYKAZh2S6WObX2pTeX1KbfgIdoKVLwXkhA='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)