UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'pGmWcTQqmLltL0fDGhx9LCIu0M11agggGCyrmoCZpw8='
WHERE
key_id = '5287a3a8848685b249f2bea78f9d3bb6d0fc3d61334b079ec0a118075e59b76f'
AND (
token = 'pGmWcTQqmLltL0fDGhx9LCIu0M11agggGCyrmoCZpw8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)