UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'hgF56aoAg4XFsg793Gr+nOhz0ffT4bHsuMP6m9lPHG0='
WHERE
key_id = 'a6ec0f58fc768218dde784f5f5bb96bc26f8c242de53215f49d6566951054d18'
AND (
token = 'hgF56aoAg4XFsg793Gr+nOhz0ffT4bHsuMP6m9lPHG0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)