UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'PBsGVAMZEO5z2oUyxs7csUs+fIcyTq8akbxSJzL+1do='
WHERE
key_id = '51e737c8b89e0f4eb024c3df2e409b9cb036f34befd5029da095a2a38121a66f'
AND (
token = 'PBsGVAMZEO5z2oUyxs7csUs+fIcyTq8akbxSJzL+1do='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)