UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'RZ1jhJKIQEaERm9FaZGJpYp5gYAl5uYUaXc6u3pGG+M='
WHERE
key_id = 'a5f258336e2e606df3b0e62261bc45e9f3a44d222864a32f72b8107e39b1dc9b'
AND (
token = 'RZ1jhJKIQEaERm9FaZGJpYp5gYAl5uYUaXc6u3pGG+M='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)