UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'c2Va0Yy4OPpv63b5aBCn4H6nxk4V8c0Zvx8r383Elzg='
WHERE
key_id = 'e80f5da743ab27b26b55639d275d87d0ce5be0f62e37d0f0144aeb740e94a228'
AND (
token = 'c2Va0Yy4OPpv63b5aBCn4H6nxk4V8c0Zvx8r383Elzg='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)