UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'DCnYjm4yKOfokRYJlz4Dj9OideMDkdx4M+i3Jvhy4y8='
WHERE
key_id = 'ae9bff0cb6d7a3feab885e4bfb69a514377f88c4a195d2488ea5e271dab800dd'
AND (
token = 'DCnYjm4yKOfokRYJlz4Dj9OideMDkdx4M+i3Jvhy4y8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)